FROM openjdk:8-jdk-alpine

MAINTAINER tanghaiyang tanghaiyang@zrcctv.com

# timezone
RUN apk add --no-cache tzdata

ARG BASE_PATH="/zerui"
ARG SERVICE_NAME="access-control-manager"
ARG PORT=9034

# set environment
ENV SERVICE_NAME="${SERVICE_NAME}"
ENV HOME_PATH="${BASE_PATH}/${SERVICE_NAME}" \
    JAVA_HOME="/usr/lib/jvm/java-1.8-openjdk"
ENV JAVA="/usr/lib/jvm/java-1.8-openjdk/bin/java" \
    CLASSPATH=".:${HOME_PATH}/conf:$CLASSPATH" \
    JVM_XMS="1g" \
    JVM_XMX="1g" \
    JVM_XMN="512m" \
    JVM_MS="128m" \
    JVM_MMS="320m"

WORKDIR ${HOME_PATH}

RUN mkdir -p target
RUN mkdir -p bin
RUN mkdir -p conf
RUN mkdir -p logs
RUN mkdir -p work

ADD ./target/${SERVICE_NAME}.jar target

COPY bin bin
RUN chmod +x bin/*.sh

COPY src/main/resources conf

EXPOSE ${PORT}

VOLUME ["${HOME_PATH}/logs", "${HOME_PATH}/work"]

ENTRYPOINT ["sh", "bin/docker-startup.sh"]
